package com.decent.controller;

import com.decent.entity.Type;
import com.decent.entity.common.Message;
import com.decent.entity.common.PageResult;
import com.decent.service.TypeService;
import com.decent.enums.MessageEnum;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.constraints.Min;

/**
 * @Author decent
 * @Create 2021/4/7 - 17:32
 * @Description
 */
@RestController
@Validated
public class TypeController {

    @Resource
    private TypeService typeService;

    /**
     * 获取品牌类型列表
     * @param pageNumber 页码
     * @param pageSize 每页数量
     * @return Message
     */
    @RequestMapping("/brand/type/list")
    public Message listBrandType(@RequestParam(defaultValue = "1") @Min(1)  Integer pageNumber,
                                 @RequestParam(defaultValue = "3") @Min(1) Integer pageSize) {
        PageInfo<Type> pageInfo = typeService.listBrandType(pageNumber, pageSize);

        PageResult pageResult = new PageResult(pageInfo);
        return new Message(MessageEnum.GENERAL_REQUEST_SUCCESS, pageResult);
    }

}
